#练习使用

list = ["apple","banana","grape","orange"]
print(list)
print(list[2])

list.append("watermalon")
list.insert(1,"grapefruit")

print(list)

list.remove("grape")

print(list)

print(list.pop())

print(list)

print(list[-2]) # 倒数第2个

print(list[1:3]) #从第2个元素到第3个元素之前，因为list[3]没打印

print(list[3])

print(list[3:1]) #倒过来是空

print(list[-3:-1]) #还是只打印2个说明最后一个不打印的

list = [["apple","banana"],["grape","orange"],["watermelen"],["grapefuit"]]
for i in range(len(list)):
    # print("list[%d]:" % i,"",)
    # print("list[%d]:" % i,"")
    print("list[%d]:" % i,)
# print("list[%d]:" % i) #出错
    for j in range(len(list[i])):
        print(list[i][j])


list_4 = ["apple","banana","orange","grape"]
print(list_4)
print(list_4.index("grape"))
print(list_4.index("orange"))
print("orange" in list_4)
list_4.sort()
print("Sorted list_4 :",list_4)